package com.ice.work.moment.scheduler.job;

import com.honeybee.cloud.framework.common.response.ResponseEntity;
import com.ice.work.moment.scheduler.service.IStationTaskService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
 * @Description 12306车站信息爬取任务
 * @Author cheng
 * @Create 2018-12-11
 * @Since 1.0.0
 */
@JobHandler(value = "stationJobHandler")
@Component
@SuppressWarnings("all")
public class StationJobHandler extends IJobHandler {
    ;
    @Autowired
    private IStationTaskService stationTaskService;

    @Override
    public ReturnT<String> execute(String params) {
        ResponseEntity<Void> responseEntity = stationTaskService.crawlingStation();
        return Objects.nonNull(responseEntity) && responseEntity.getSuccess() ? IJobHandler.SUCCESS : IJobHandler.FAIL;
    }

}
